
import { ref } from 'vue'
import { defineStore } from "pinia"

export const useStore = defineStore("default", () => {
  const viewer = ref(null)

  const setUserInfo = (userInfo) => {
    if (userInfo === null) {
      viewer.value = null
      return
    }

    viewer.value = {
      staff: {
        name: userInfo.username,
        id: userInfo.id,
        phoneNumber: userInfo.phone_number || '',
        email: userInfo.email || ''
      }
    }
  }

  return {
    viewer,
    setUserInfo
  }
})
